package com.sq.partner.manager.service.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.BaseDao;
import com.sq.partner.manager.dao.CommonDao;
import com.sq.partner.manager.dao.IGatewayUserDao;
import com.sq.partner.manager.dao.impl.BaseDaoImpl;
import com.sq.partner.manager.mybatis.model.CoreDept;
import com.sq.partner.manager.mybatis.model.GatewayRole;
import com.sq.partner.manager.mybatis.model.GatewayUser;
import com.sq.partner.manager.mybatis.model.GatewayUserRole;
import com.sq.partner.manager.service.IGatewayUserService;
import com.sq.partner.manager.util.DBUtil;
import com.sq.partner.manager.util.LogUtil;
import com.sq.partner.manager.util.Page;
import com.sq.partner.manager.util.SqlUtil;
@Service
public class GatewayUserServiceImpl implements IGatewayUserService {
	@Resource
	private IGatewayUserDao userDao;
	
	private static Logger logger = LogUtil.getLog(BaseDaoImpl.class);	
	/**
	 * 分页查询
	 */
	@Override
	public Page queryPage(Page page,Integer pageIndex,Map<String,String> param,GatewayUser user) throws Exception {
		return userDao.queryPage(page, pageIndex,param, user);
	}
	
	/**
	 * 根据用户ID删除用户
	 */
	@Override
	public void delUserById(Long userid) throws Exception {
		GatewayUser user = new GatewayUser();
		user.setUserid(userid);
		userDao.delUserById(user);
	}

	@Override
	public GatewayUser queryUserById(Long userid) throws Exception {
		return userDao.queryUserById(userid);
	}

	@Override
	public boolean saveUser(GatewayUser user) throws Exception {
		return userDao.saveUser(user);
	}

	@Override
	public boolean modifyPwd(GatewayUser user) throws Exception {
		return userDao.modifyPwd(user);
	}

	@Override
	public List<GatewayRole> getUserRole(Long userid) throws Exception {
		return userDao.getUserRole(userid);
	}

	@Override
	public boolean addUser(GatewayUser user) throws Exception {
		return userDao.addUser(user);
	}

	@Override
	public GatewayUser queryUserCount(Map<String, String> map) throws Exception {
		return userDao.queryUserCountByMap(map);
	}
	@Override
	public List<GatewayRole> queryAllRoles(Map<String, String> map) throws Exception {
		return userDao.queryAllRoles(map);
	}

	@Override
	public List<GatewayRole> queryAllRolesByUser(GatewayUser user)
			throws Exception {
		return userDao.queryAllRolesByUser(user);
	}
	@Override
	public Page queryRolesPageByUser(Page page,Integer pageIndex,Map<String,String> param,GatewayUser user) throws Exception{
		return userDao.queryRolesPageByUser(page,pageIndex,param,user);
	}
	@Override
	public boolean setRoleToUser(GatewayUserRole role) throws Exception {
		return userDao.setRoleToUser(role);
	}

	@Override
	public boolean removeAllRolesFromUser(Long userId)
			throws Exception {
		return userDao.removeRolesFromUser(userId);
	}

	@Override
	public void delUserRoleUserid(Long userid) throws Exception {
		userDao.delUserRoleUserid(userid);
	}

	@Override
	public List<GatewayUserRole> getUserCountOfOneRole(Map<String, Long> map)
			throws Exception {
		return userDao.getUserCountOfOneRole(map);
	}

	@Override
	public List<CoreDept> queryDeptCode(GatewayUser user) throws Exception {
		return userDao.queryDeptCode(user);
	}

	
}
